package com.study.leetcode;

public class Solution_860 {
    public static boolean lemonadeChange(int[] bills) {
        int five = 0;
        int ten = 0;
        for (int bill : bills) {
            if (bill == 5) {
                five++;
            } else if (bill == 10) {
                five--;
                ten++;
            } else if (ten > 0) {
                ten--;
                five--;
            } else {
                five -= 3;
            }
            if (five < 0) {
                return false;
            }
        }
        return true;
    }


    public static void main(String[] args) {
        int[] bills1 = {5, 5, 5, 10, 20};
        boolean b = lemonadeChange(bills1);
        System.out.println("b = " + b);
        int[] bills2 = {5, 5, 10, 10, 20};
        b = lemonadeChange(bills2);
        System.out.println("b = " + b);
    }
}
